﻿package src.utils{
	import flash.display.DisplayObjectContainer;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	public class FpsCounterHolder {
		private var fpsCounter:FpsCounter;
		private var fpsText:TextField;
		private var contentHolder:DisplayObjectContainer;
		
		public function FpsCounterHolder(contentHolder:DisplayObjectContainer) {
			this.contentHolder = contentHolder;
			init();
		}
		
		private function init() {
			fpsCounter = new FpsCounter();
			fpsText = new TextField();
			fpsText.autoSize = TextFieldAutoSize.LEFT;
			fpsText.textColor = 0xff0000;
		}
		
		public function update():void {
			fpsCounter.tick();
			fpsText.text = "FPS " + fpsCounter.getFps().toString();
		}
		
		public function show():void {
			contentHolder.addChild(fpsText);
			fpsText.x = 100;
		}
		
		public function hide():void {
			contentHolder.removeChild(fpsText);
		}

	}
	
}
